package com.ordering.service.product.impl;

import com.ordering.constant.ResultResponse;
import com.ordering.dao.product.ProductDao;
import com.ordering.dao.product.impl.ProductDaoImpl;
import com.ordering.entity.Page;
import com.ordering.entity.Product;
import com.ordering.service.product.ProductService;

public class ProductServiceImpl implements ProductService
{
    ProductDao productDao = new ProductDaoImpl();
    @Override
    public ResultResponse add(Product product)
    {
        return productDao.add(product);
    }

    @Override
    public ResultResponse delect(Product product)
    {
        return productDao.delect(product);
    }

    @Override
    public ResultResponse get4page(Product product, Page page)
    {
        return productDao.get4page(product, page); 
    }

	@Override
	public ResultResponse count(Product product) {
		// TODO Auto-generated method stub
	    return productDao.count(product);
	}

	@Override
	public Product getById(long id) {
		// TODO Auto-generated method stub
		return productDao.getById(id);
	}

	@Override
	public ResultResponse updateStatus(long id, int status) {
		// TODO Auto-generated method stub
		ResultResponse response = new ResultResponse();
		try {
			response.setResult(productDao.updateStatus(id, status));
		} catch (Exception e) {
			response.setCode(ResultResponse.CODE_Fail);
			response.setMessage(e.getMessage());
			e.printStackTrace();
		}
		return response;
		
	}

	@Override
	public ResultResponse update(Product product) {
		return productDao.update(product);
	} 

}
